<?php 
$jobdetails = $_['jobdetails'];
$userid = $jobdetails->employer_id;
?>

<div id="onlinetestbody" class="rulesbody">
   <?php if(empty($_['showsheets'])): ?>
      <div class="set_quence_content">
         <div class="notbegin yahei large"><i></i>尚无试卷, 请您创建试卷</div>
         <div class="job_createtest job_testnoconfig"><a href="<?php echo OC_Helper::linkToRoute("jobpos_editsheet", array('jobid'=>$jobdetails->id, 'job_title'=>$jobdetails->job_title)); ?>">创建新试卷</a></div>

      </div>
   <?php else: ?>
      <div class="set_quence_content">
         <div class="successuploadfile">
            <div class="uploadfile_title">
            <?php
               if($_['jobsheet_details']){
                  echo '<b>已选试题：</b><span style="color:#666;" class="sheetname">'.$_['jobsheet_details']->title.'</span><i class="removetest"></i>';
               } else {
                  echo '<span style="color:#999999;">请在以下试题中选择一个</span>';
               }
            ?>
            </div>
            <form action="#">
               <table class="companysheets" width="100%" border="0" cellpadding="0" cellspacing="0">
               <?php 
                     $i = 0;
                     foreach($_['showsheets'] as $key=>$value){
                           if($i%2 == 0){
                              if($value->selected_by_jobs && in_array($jobdetails->id, explode(',', $value->selected_by_jobs)) ){
                                 echo '<tr>'.
                                       '<td class="selected" width="50%">'.
                                       '<i></i><span class="sheetname" style="color:#666;">'.$value->title.'</span>'.
                                       '<a target="_blank" href="'.OC_Helper::linkToRoute("jobpos_previewsheet", array('id'=>$value->sheetid, 'jobid'=>$jobdetails->id, 'job_title'=>$value->title)).'"> [ 预览 ] </a>';
                                 if ($value->owner == $userid) {
                                    echo '<a target="_blank" href="'.OC_Helper::linkToRoute("jobpos_editsheet", array('id'=>$value->sheetid, 'jobid'=>$jobdetails->id, 'title'=>$value->title)).'"> [ 修改 ] </a>';
                                    if ($value->hits == 0)
                                       echo '<a href="javascript:;" class="delete_sheet"> [ 删除 ] </a>';
                                 }
                                 echo '<span class="sheetid" style="display:none;">'.$value->sheetid.'</span>'.
                                       '<span class="error server" style="display:none;"></span>'.
                                       '</td>';
                              } else {
                                 echo '<tr>'.
                                       '<td width="50%">'.
                                       '<i></i><span class="sheetname" style="color:#666;">'.$value->title.'</span>'.
                                       '<a target="_blank" href="'.OC_Helper::linkToRoute("jobpos_previewsheet", array('id'=>$value->sheetid, 'jobid'=>$jobdetails->id, 'job_title'=>$value->title)).'"> [ 预览 ] </a>';
                                 if ($value->owner == $userid) {
                                    echo '<a target="_blank" href="'.OC_Helper::linkToRoute("jobpos_editsheet", array('id'=>$value->sheetid, 'jobid'=>$jobdetails->id, 'title'=>$value->title)).'"> [ 修改 ] </a>';
                                    if ($value->hits == 0)
                                       echo '<a href="javascript:;" class="delete_sheet"> [ 删除 ] </a>';
                                 }
                                 echo '<span class="sheetid" style="display:none;">'.$value->sheetid.'</span>'.
                                       '<span class="error server" style="display:none;"></span>'.
                                       '</td>';
                              }
                                 
                           } else {
                              if($value->selected_by_jobs && in_array($jobdetails->id, explode(',', $value->selected_by_jobs)) ){
                                 echo '<td class="selected" width="50%">'.
                                       '<i></i><span class="sheetname" style="color:#666;">'.$value->title.'</span>'.
                                       '<a target="_blank" href="'.OC_Helper::linkToRoute("jobpos_previewsheet", array('id'=>$value->sheetid, 'jobid'=>$jobdetails->id, 'job_title'=>$value->title)).'"> [ 预览 ] </a>';
                                 if ($value->owner == $userid) {
                                    echo '<a target="_blank" href="'.OC_Helper::linkToRoute("jobpos_editsheet", array('id'=>$value->sheetid, 'jobid'=>$jobdetails->id, 'title'=>$value->title)).'"> [ 修改 ] </a>';
                                    if ($value->hits == 0)
                                       echo '<a href="javascript:;" class="delete_sheet"> [ 删除 ] </a>';
                                 }
                                 echo '<span class="sheetid" style="display:none;">'.$value->sheetid.'</span>'.
                                       '<span class="error server" style="display:none;"></span>'.
                                       '</td>'.
                                       '</tr>';
                              } else {
                                 echo '<td width="50%">'.
                                       '<i></i><span class="sheetname" style="color:#666;">'.$value->title.'</span>'.
                                       '<a target="_blank" href="'.OC_Helper::linkToRoute("jobpos_previewsheet", array('id'=>$value->sheetid, 'jobid'=>$jobdetails->id, 'job_title'=>$value->title)).'"> [ 预览 ] </a>';
                                 if ($value->owner == $userid) {
                                    echo '<a target="_blank" href="'.OC_Helper::linkToRoute("jobpos_editsheet", array('id'=>$value->sheetid, 'jobid'=>$jobdetails->id, 'title'=>$value->title)).'"> [ 修改 ] </a>';
                                    if ($value->hits == 0)
                                       echo '<a href="javascript:;" class="delete_sheet"> [ 删除 ] </a>';
                                 }
                                 echo '<span class="sheetid" style="display:none;">'.$value->sheetid.'</span>'.
                                       '<span class="error server" style="display:none;"></span>'.
                                       '</td>'.
                                       '</tr>';
                              }
                           }
                           $i++;
                        }
                     if($i == 1){
                        echo '</tr>';
                     } else if($i%2 !=0){
                        echo '<td width="50%"></td></tr>';
                     }
                   ?>
               </table>
               <input type="hidden" name="requesttoken" value="<?php echo $_['requesttoken'] ?>" id="requesttoken">
            </form>
            <div class="job_createtest">
               <a href="<?php echo OC_Helper::linkToRoute("jobpos_editsheet", array('jobid'=>$jobdetails->id, 'job_title'=>$jobdetails->job_title)); ?>">创建新试卷</a>
            </div>
         </div>
      </div>
   <?php endif; ?>

</div>
